package com.itheima.Jiuye16;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Date;
import java.util.Properties;

public class Zuoye1 {
    public static void main(String[] args) throws Exception {
        //获取类加载器
        ClassLoader classLoader = Zuoye1.class.getClassLoader();
        //获取指定路径下的资源
        InputStream stream = classLoader.getResourceAsStream("prop.properties");
        //创建properties集合
        Properties p = new Properties();
        //将指定路径的资源一次性存储到集合
        p.load(stream);
        //关流
        stream.close();
        //根据键获取到值，即存到集合中的资源文件数据
        String a = p.getProperty("classname");
        //创建对应的Class对象
        Class<?> aClass = Class.forName(a);
        //获取构造器
        Constructor<?> constructor = aClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        //
        Object o = constructor.newInstance();

        String s = p.getProperty("methodname");
        Method method = aClass.getDeclaredMethod(s, String.class);
        System.out.println(method);
        method.setAccessible(true);
      //  Object invoke = method.invoke(o);
        Person person = (Person) method.invoke(o,"E:\\IEDA_Demo\\basic\\mJiuYe\\a.txt");
    }
}
